package com.bdqn.rabbitmqporducer1.config;

import com.fasterxml.jackson.databind.ObjectMapper;
import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

//@Configuration
public class DirectConfig {
    @Bean
    public Queue MyDirectQueue1() {
        return new Queue("MyDirectQueue1", true);
    }

    @Bean
    public Queue MyDirectQueue2() {
        return new Queue("MyDirectQueue2", true);
    }

    @Bean
    DirectExchange MyDirectExchange() {
        return new DirectExchange("MyDirectExchange", true, false);
    }

    @Bean
    Binding bindingDirect() {
        return BindingBuilder.bind(MyDirectQueue1()).to(MyDirectExchange()).with("MyDirectRouting");
    }

    @Bean
    DirectExchange AloneDirectExchange() {
        return new DirectExchange("AloneDirectExchange");
    }

    @Bean
    public Queue ConfirmQueue() {
        return new Queue("ConfirmQueue", true);
    }

    @Bean
    DirectExchange ConfirmExchange() {
        return new DirectExchange("ConfirmExchange", true, false);
    }

    @Bean
    Binding bindingConfirm() {
        return BindingBuilder.bind(ConfirmQueue()).to(ConfirmExchange()).with("ConfirmRouting");
    }

    @Bean
    MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}
